import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { User } from '@/type/user'

export const useUserStore = defineStore(
  'user',
  () => {
    const user = ref({} as User)

    const setUser = (userData: User) => {
      user.value = userData
    }

    const delUser = () => {
      user.value = {} as User
    }
    return {
      user,
      setUser,
      delUser,
    }
  },
  {
    persist: true,
  },
)
